﻿using System.Collections.Generic;
using System.Data.Common;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using PTop.Data;
using PTop.Domain.Entity.Article;
using PTop.Domain.IRepository.Article;

namespace PTop.Repository.Article
{
    /// <summary>
    /// TagRepository
    /// </summary>	
    public class TagRepository : RepositoryBase<TagEntity>, ITagRepository
    {
        public List<TagEntity> FindListByArticle(string articleId)
        {
            const string sql = @"SELECT * FROM Train_Tag
WHERE F_Id IN 
(
	SELECT F_TagId 
	FROM Train_ArticleTagRelation
	WHERE F_ArticleId = @articleId
)";
            DbParameter[] parameter = 
            {
                 new MySqlParameter("@articleId",articleId)
            };
            return FindList(sql, parameter);
        }
    }
}